home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8266 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: rahul.net!a2i!news
  2. From: terris@rahul.net (Terris Linenbach)
  3. Newsgroups: comp.lang.c++
  4. Subject: *Fixed* Serious trouble with STL and NT/Win95
  5. Date: 16 Feb 1996 08:26:28 GMT
  6. Organization: a2i network
  7. Message-ID: <4g1f3k$adq@hustle.rahul.net>
  8. References: <4frrve$pnr@hustle.rahul.net>
  9. NNTP-Posting-Host: 534.rahul.net
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.6
  13.  
  14. I eliminated all of the statics.
  15.  
  16. Keep an eye on 
  17.  
  18. HTTP: www.rahul.net/terris/
  19.  
  20. For a new thread-safe, DLL-friendly version of HP's STL.  It will be there in 
  21. a few days.  You will still have to put critical sections around code that 
  22. uses the same object in different threads.
  23.  
  24. Please let me know of any bugs you may find.
  25.  
  26. There's no such thing as a free lunch:  taking away the statics means memory 
  27. isn't managed as efficiently.  Time and space penalties.  I will leave the 
  28. previous version of the STL on my FTP site.
  29.  
  30. If you are going to do serious work with the STL I recommend you buy it from a 
  31. vendor.  Rogue Wave will have a version that works with 32-bit MFC in April.  
  32. (It's sold separately from TOOLS.H++.)
  33.  
  34. - Terris
  35.  
  36.  
  37. In article <4frrve$pnr@hustle.rahul.net>, terris@rahul.netc says...
  38. >
  39. >The following applies to HP's STL implementation, including the version
  40. >shipped in Microsoft Visual C++ 4.0.  Credit goes to David
  41. >Williams.
  42. >
  43. >1. It is not thread-safe.  Do not attempt to perform
  44. >   something on the same "type" of container in two different threads
  45. >   at the same time.  (You are in trouble even if you try to do this with
  46. >   _different_ objects -- notice I said "type" and not "object")
  47. >
  48. >   By "type", I mean a particular instantiation, such as
  49. >      vector< int >
  50. >
  51. >   This is because most STL classes have statics in them that are not
  52. >   accessed in a thread-safe manner.
  53. >
  54. >2. Do not pass *most* STL containers across DLL/EXE boundaries.  Vectors
  55. >   are OK.
  56. >
  57. >   This is because most STL classes have statics.  In 32-bit
  58. >   Windows, DLLs and EXEs get their own copies of the statics.  This
  59. >   causes problems.
  60. >
  61. >   Vectors are not affected because vectors only have a static allocator,
  62. >   which doesn't have any data or any virtual member functions.
  63. >
  64. >   If you try something like passing a set to a function in a 
  65. >   DLL, your program will crash.
  66. >
  67.  
  68.